// pages/myinfo/Infomation/myinfomation/myinfomation.js
const util = require('../../../../utils/util.js');
const md5 = require('../../../../utils/md5.js');
const http = require('../../../../utils/http.js');
Page({

    /**
     * 页面的初始数据
     */
    data: {
        msg: []
    },

    time() {
        console.log(util.year())
    },
    /**
     * 生命周期函数--监听页面加载
     */
    onLoad: function (options) {

    },

    /**
     * 生命周期函数--监听页面初次渲染完成
     */
    onReady: function () {

    },
    delectChoose(e) {
        let _this = this
        let data = {
            method: 'UserMessage.messageDel',
            messageId: e.target.dataset.id,
            token: wx.getStorageSync('token')
        }
        let arr = http.sorts(data)
        data.sign = md5.hex_md5(arr)
        http._post(data, res => {
            console.log(res)
            if (res.data.code == 0) {
                http.toast(res.data.msg)

                _this.onShow()
            } else {
                http.toast(res.data.msg)
            }
        })
    },
    /**
     * 生命周期函数--监听页面显示
     */
    onShow: function () {
        let _this = this
        let data = {
            method: 'UserMessage.messageList',
            type: 3,
            token: wx.getStorageSync('token')
        }
        let arr = http.sorts(data)
        data.sign = md5.hex_md5(arr)
        http._post(data, res => {
            console.log(res.data)
            if (res.data.code == 0) {
                res.data.data.newList == '' ? http.toast('没有通知消息') : _this.setData({ msg: res.data.data.newList })
            } else {
                http.toast(res.data.msg)
            }
        })
    },

    /**
     * 生命周期函数--监听页面隐藏
     */
    onHide: function () {

    },

    /**
     * 生命周期函数--监听页面卸载
     */
    onUnload: function () {

    },

    /**
     * 页面相关事件处理函数--监听用户下拉动作
     */
    onPullDownRefresh: function () {

    },

    /**
     * 页面上拉触底事件的处理函数
     */
    onReachBottom: function () {

    },

    /**
     * 用户点击右上角分享
     */
    onShareAppMessage: function () {

    }
})